import api from '../../server/api';

const state = {
    clist:[],
    cget:[],
}

const getters = {}

const actions = {
    // 由type页面跳转调用的方法
    TypeContentList( {commit} ,fcid=""){
        if(fcid==""){
            return
        }
        api.loadDataByLike({
            page:1,
            sort:'pop',
            cKey:"16",
            fcid,
            title:"综合"
        })
        .then(( {result} )=>{
            commit("setClist",result.wall.docs);
            commit("setCget",result);
            //console.log('11111',result)
        })
    },
    TypeContentListClass({commit},params={fcid:"10062603",sort:"pop"}){
        api.loadDataByLike({
            page:1,
            sort:params.sort,
            cKey:"h5-cube",
            fcid:params.fcid
        })
        .then(( {result} )=>{
            commit("setClist",result.wall.docs);
            commit("setCget",result);
        })
    },
    // 搜索页面跳转调用的方法
    TypeContentBySearch({commit},q=""){
        if(q==""){
            return
        }
        api.loadDataByLike({
            page:1,
            sort:"pop",
            cKey:46,
            q
        })
        .then(( {result} )=>{
            console.log(result)
            commit("setClist",result.wall.docs);
            commit("setCget",result);
        })     
    }
}
    
const mutations = {
    setClist(state,data){
        state.clist = data
    }, 
    setCget(state,data){
        state.cget = data
    },  
}

export default {
    state,
    actions,
    mutations,
    getters
}
